from flask import Flask, url_for, render_template, redirect, request

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('login.html')


@app.route('/login', methods=['POST', 'GET'])
def login():
    if request.method == "POST":
        info_str = ""
        info_dict = {}
        user = request.form
        for i in user:
            info_str += user[i]
            info_str += ';'
            info_dict[i] = user[i]
            print(info_dict)
        dest = ""
        if info_dict['color_id'] == '1':
            dest = "GreenPassCode.html"
        elif info_dict['color_id'] == '2':
            dest = "RedPassCode.html"
        elif info_dict['color_id'] == '3':
            dest = "GoldPassCode.html"
        elif info_dict['color_id'] == '4':
            dest = "BluePassCode.html"
        elif info_dict['color_id'] == '5':
            dest = "PinkPassCode.html"
        elif info_dict['color_id'] == '6':
            dest = "BlackPassCode.html"
        return render_template(dest
                               , name=info_dict['name'], school=info_dict['school']
                               , id_no=info_dict['id_no'], id=info_dict['id']
                               , begin_time=info_dict['begin_time'], end_time=info_dict['end_time']
                               , vaccine_num=info_dict['vaccine_num']
                               )
    else:
        print("get")


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)
